﻿<UserControl
    x:Class="Adaptive.ReactiveTrader.Client.UI.Connectivity.ConnectivityStatusView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="using:Microsoft.Xaml.Interactivity"
    xmlns:core="using:Microsoft.Xaml.Interactions.Core"
    mc:Ignorable="d"
    d:DesignWidth="800"
    d:DesignHeight="50">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Styles/Brushes.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <SolidColorBrush x:Key="NormalStatusBackgroundBrush" Color="#FFDEE3E8" />
        </ResourceDictionary>
    </UserControl.Resources>
    <Border x:Name="RootBorder" Background="{StaticResource NormalStatusBackgroundBrush}">
        <i:Interaction.Behaviors>
            <core:DataTriggerBehavior Binding="{Binding Disconnected}" Value="True">
                <core:ChangePropertyAction TargetObject="{Binding ElementName=RootBorder}" PropertyName="Background" Value="{StaticResource ErrorBackgroundBrush}" />
                <core:ChangePropertyAction TargetObject="{Binding ElementName=Text}" PropertyName="Foreground" Value="White" />
            </core:DataTriggerBehavior>
            <core:DataTriggerBehavior Binding="{Binding Disconnected}" Value="False">
                <core:ChangePropertyAction TargetObject="{Binding ElementName=RootBorder}" PropertyName="Background" Value="{StaticResource NormalStatusBackgroundBrush}" />
                <core:ChangePropertyAction TargetObject="{Binding ElementName=Text}" PropertyName="Foreground" Value="Black" />
            </core:DataTriggerBehavior>
        </i:Interaction.Behaviors>

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <TextBlock x:Name="Text" Margin="10,3" FontSize="14">
                <Run Text="{Binding Status, Mode=OneWay}"  />
                <Run Text=" | "/>
                <Run Text="E2E Lat.:" />
                <Run Text="{Binding ServerClientLatency, Mode=OneWay}"  />
                <Run Text="ms"/>
                <Run Text=" | "/>
                <Run Text="UI Upd.:" />
                <Run Text="{Binding UiUpdates, Mode=OneWay}" />
                <Run Text="/sec" />
                <Run Text=" | "/>
                <Run Text="Server Upd.:" />
                <Run Text="{Binding TicksReceived, Mode=OneWay}" />
                <Run Text="/sec" />
                <Run Text=" | "/>
                <Run Text="UI Lat.:" />
                <Run Text="{Binding UiLatency, Mode=OneWay}"  />
                <Run Text="ms"/>
            </TextBlock>

            <StackPanel Orientation="Horizontal" Grid.Column="1">
                <HyperlinkButton NavigateUri="http://www.weareadaptive.com">
                    <Image Source="ms-appx:///Assets/statusbar_logo.png" Stretch="None" />
                </HyperlinkButton>
            </StackPanel>
        </Grid>
    </Border>

</UserControl>
